package com.wondersgroup.insurance.dnuilearn.beahvior;

import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.CoordinatorLayout.Behavior;
import android.util.AttributeSet;
import android.view.View;

import com.wondersgroup.insurance.dnuilearn.R;

/**
 * @author 黄赛赛
 * @version V1.0
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}()
 * @date 2017/7/13 0013 23:31
 */
public class TranceBehavior extends Behavior {

    /**
     * 写构造方法   不写奔溃
     * @param context
     * @param set
     */
    public TranceBehavior(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    /**
     * CoordinatorLayout  调用此方法
     *
     * View child      TextView
     *
     *  CoordinatorLayout遍历所有的子控件
     *调用多次
     *
     * boolean   告诉父 容器  我是否需要监听它
     *   dependency   Button
     */
    @Override
    public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {


        return dependency.getId() == R.id.view1;
    }


    @Override
    public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
//        if (child.getId() == R.id.view2){
            child.setX(dependency.getX());
            child.setY(dependency.getY()+dependency.getHeight());
//        }
        return true;
    }
}
